package com.yidu.t299.dao.ljc;
import com.yidu.t299.domain.ljc.Storeroom;
import org.apache.ibatis.annotations.*;
import java.util.List;
/**
 * @author 刘建常
 * @version 1.0
 * @description
 * @date:2023/3/10 9:22
 */
@Mapper
public interface StoreroomMapper {
    /**
     * 增加
     * @param record
     * @return
     */
    @Insert({
            "insert into out_storeroom (out_id,goods_id,goods_number,stock_id,pull_id,schoolthing,back_state)" +
                    " values " +
                    "(#{outId,jdbcType=INTEGER}, #{goodsId,jdbcType=INTEGER}," +
                    "#{goodsNumber,jdbcType=INTEGER},#{stockId,jdbcType=INTEGER}," +
                    "#{pullId,jdbcType=INTEGER},#{schoolthing,jdbcType=VARCHAR}," +
                    "#{backState,jdbcType=VARCHAR})"
    })
    int insert(Storeroom record);

    /**
     * 删除
     * @param outId
     * @return
     */
    @Delete({
            "delete from out_storeroom" +
                    " where out_id = #{outId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(@Param("outId") Integer outId);

    /**
     * 修改
     * @param record
     * @return
     */
    @Update({
            "update out_storeroom"+
            " set goods_id = #{goodsId,jdbcType=INTEGER},"+
                    "goods_number = #{goodsNumber,jdbcType=INTEGER},"+
                    "stock_id = #{stockId,jdbcType=INTEGER},"+
                    "pull_id = #{pullId,jdbcType=INTEGER},"+
                    "schoolthing = #{schoolthing,jdbcType=VARCHAR},"+
                    "back_state = #{backState,jdbcType=VARCHAR}"+
                    " where out_id = #{outId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Storeroom record);

    /**
     * 查询
     * @param outId
     * @return
     */
    @Select({
            "select" +
                    "out_id,goods_id,goods_number,stock_id,pull_id,schoolthing,back_state" +
                    " from out_storeroom" +
                    " where out_id = #{outId,jdbcType=INTEGER}"
    })
    @Results(id = "StoreroomMap",value = {
            @Result(id = true,column = "out_id",property = "outId"),
            @Result(column = "goods_id",property = "goodsId"),
            @Result(column = "goods_number",property = "goodsNumber"),
            @Result(column = "stock_id",property = "stockId"),
            @Result(column = "pull_id",property = "pullId"),
            @Result(column = "schoolthing",property = "schoolthing"),
            @Result(column = "back_state",property = "backState")
    })
    Storeroom selectByPrimaryKey(Integer outId);

    /**
     * 分页查询数据信息
     * @param rows
     * @param page
     * @param condition
     * @return
     */
    @Select("select * from out_storeroom where 1=1 ${condition} limit #{page},#{rows}")
    @ResultMap("StoreroomMap")
    List<Storeroom> selectByPage(@Param("rows") int rows, @Param("page") int page, @Param("condition") String condition);

    /**
     * 条件查询数据
     * @param condition
     * @return
     */
    @Select("select count(*) from out_storeroom where 1=1 ${condition}")
    int selectCount(@Param("condition") String condition);

}
